import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: xiaotutu
 * Date: 2024-03-08
 * Time: 10:01
 */
class Student {

    public String name;
    public int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }
}

public class Test {

    @Override
    public boolean equals(Object obj) {
        return super.equals(obj);
    }

    public static void main(String[] args) {
        String str = "   hello  world   " ;
        System.out.println("["+str+"]");
        System.out.println("["+str.trim()+"]");
    }

    public static void main13(String[] args) {
        String str = "hello world" ;
        System.out.println(str.substring(5));
        System.out.println(str.substring(0, 5));
    }
    public static void main12(String[] args) {
        String str = "name=zhangsan&age=18" ;
        String[] result = str.split("&") ;
        for (int i = 0; i < result.length; i++) {
            String[] temp = result[i].split("=");
            System.out.println(temp[0] + " = " + temp[1]);
        }
        /*for (String s: result) {
            System.out.println(s);
        }*/

    }
    public static void main11(String[] args) {
        String str = "192.168.1.1" ;
        String[] result = str.split("\\.");
        for (String s: result) {
            System.out.println(s);
        }
    }

    public static void main10(String[] args) {
        String str = "hello world hello bit" ;
        // String[] result = str.split(" ");
        String[] result = str.split(" ",3);
        for (String s: result) {
            System.out.println(s);
        }
    }

    public static void main9(String[] args) {
        String str = "hello world" ;
        // System.out.println(str.replaceAll("l", "-"));
        System.out.println(str.replaceFirst("l","\\\\"));
    }

    public static void main8(String[] args) {
        String s = String.format("%d-%d-%d", 2019, 9,14);
        System.out.println(s);
    }
    public static void main7(String[] args) {
        String s = "hello";
        char[] array = s.toCharArray();
        System.out.println(Arrays.toString(array));

        String s2 = new String(array);
        System.out.println(s2);
    }

    public static void main6(String[] args) {
        String s1 = "hello";
        String s2 = "HELLO";
        System.out.println(s1.toUpperCase());
        System.out.println(s2.toLowerCase());
    }

    public static void main5(String[] args) {
        String s1 = String.valueOf(1234);
        String s2 = String.valueOf(12.34);
        String s3 = String.valueOf(true);
        String s4 = String.valueOf(new Student("Hanmeimei", 18));
        System.out.println(s1);
        System.out.println(s2);
        System.out.println(s3);
        System.out.println(s4);
        System.out.println("==============");

        int data1 = Integer.parseInt("1234");
        System.out.println(data1);
        double data2 = Double.parseDouble("12.34");
        System.out.println(data2);

    }

    public static void main4(String[] args) {
        String s = "aaabbbcccaaabbbccc";
        System.out.println(s.charAt(3));
        System.out.println(s.indexOf('b'));
        System.out.println(s.indexOf('c', 17));
        System.out.println(s.indexOf("abc"));
        System.out.println(s.indexOf("ccc", 15));
        System.out.println(s.lastIndexOf('b'));
        System.out.println(s.lastIndexOf('c',17));
        System.out.println(s.lastIndexOf("ccc"));
        System.out.println(s.lastIndexOf("ccc", 17));
    }

    public static void main3(String[] args) {
        String s1 = new String("abc");
        String s2 = new String("ac");
        String s3 = new String("ABc");
        String s4 = new String("abcdef");
        System.out.println(s1.compareToIgnoreCase(s2));
        System.out.println(s1.compareToIgnoreCase(s3));
        System.out.println(s1.compareToIgnoreCase(s4));
    }

    public static void main2(String[] args) {
        String s1 = new String("abc");
        String s2 = new String("ac");
        String s3 = new String("abcd");
        String s4 = new String("abcdef");

        System.out.println(s1.compareTo(s2));
        System.out.println(s1.compareTo(s3));
        System.out.println(s1.compareTo(s4));
    }

    public static void main1(String[] args) {
        String s1 = new String("hello");
        String s2 = new String("hello");
        String s3 = new String("Hello");


        System.out.println(s1 == s2);
        System.out.println(s1 == s3);

        System.out.println(s1.equals(s2));
        System.out.println(s1.equals(s3));
    }
}
